home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / JFC.bin / MultiMenuUI.java < prev    next >
Text File  |  1998-06-30  |  5KB  |  159 lines

  1. /*
  2.  * @(#)MultiMenuUI.java    1.11 98/02/02
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20.  
  21. package com.sun.java.swing.plaf.multi;
  22.  
  23. import java.util.Vector;
  24. import java.io.Serializable;
  25. import com.sun.java.swing.*;
  26. import java.awt.*;
  27. import java.awt.event.*;
  28. import com.sun.java.swing.plaf.*;
  29.  
  30. /**
  31.  * MultiMenuUI implementation
  32.  * <p>
  33.  * Warning: serialized objects of this class will not be compatible with
  34.  * future swing releases.  The current serialization support is appropriate
  35.  * for short term storage or RMI between Swing1.0 applications.  It will
  36.  * not be possible to load serialized Swing1.0 objects with future releases
  37.  * of Swing.  The JDK1.2 release of Swing will be the compatibility
  38.  * baseline for the serialized form of Swing objects.
  39.  *
  40.  * @version 1.11 02/02/98
  41.  * @author Willie Walker
  42.  */
  43. public class MultiMenuUI extends MenuUI 
  44.     implements Serializable {
  45.  
  46.     /**
  47.      * The Vector containing the real UI's.  This is populated 
  48.      * in the call to createUI, and can be obtained by calling
  49.      * getUIs.  The first element is guaranteed to the real UI 
  50.      * obtained from the default look and feel.
  51.      */
  52.     protected Vector uis = new Vector();
  53.  
  54. ////////////////////
  55. // Common UI methods
  56. ////////////////////
  57.  
  58.     public static ComponentUI createUI(JComponent c) {
  59.         ComponentUI mui = new MultiMenuUI();
  60.         return MultiLookAndFeel.createUIs(mui,
  61.                                           ((MultiMenuUI) mui).uis,
  62.                                           c);
  63.     }
  64.  
  65.     /**
  66.      * Return the list of UI's associated with this multiplexing UI.  This 
  67.      * allows processing of the UI's by an application aware of multiplexing 
  68.      * UI's on components.
  69.      */
  70.     public ComponentUI[] getUIs() {
  71.         return MultiLookAndFeel.uisToArray(uis);
  72.     }
  73.  
  74. //////////////////////
  75. // ComponentUI methods
  76. //////////////////////
  77.  
  78.     public void installUI(JComponent c) {
  79.         for (int i = 0; i < uis.size(); i++) {
  80.             ((ComponentUI) (uis.elementAt(i))).installUI(c);
  81.         }
  82.     }
  83.  
  84.     public void uninstallUI(JComponent c) {
  85.         for (int i = 0; i < uis.size(); i++) {
  86.             ((ComponentUI) (uis.elementAt(i))).uninstallUI(c);
  87.         }
  88.     }
  89.   
  90.     public void paint(Graphics g, JComponent c) {
  91.         for (int i = 0; i < uis.size(); i++) {
  92.             ((ComponentUI) (uis.elementAt(i))).paint(g,c);
  93.         }
  94.     }
  95.       
  96.     public void update(Graphics g, JComponent c) {
  97.         for (int i = 0; i < uis.size(); i++) {
  98.             ((ComponentUI) (uis.elementAt(i))).update(g,c);
  99.         }
  100.     }
  101.  
  102.     public Dimension getPreferredSize(JComponent c) {
  103.         return ((ComponentUI) (uis.elementAt(0))).getPreferredSize(c);
  104.     }
  105.  
  106.     public Dimension getMinimumSize(JComponent c) {
  107.         return ((ComponentUI) (uis.elementAt(0))).getMinimumSize(c);
  108.     }
  109.  
  110.     public Dimension getMaximumSize(JComponent c) {
  111.         return ((ComponentUI) (uis.elementAt(0))).getMaximumSize(c);
  112.     }
  113.  
  114.     public boolean contains(JComponent c, int x, int y) {
  115.         return ((ComponentUI) (uis.elementAt(0))).contains(c,x,y);
  116.     }
  117.  
  118. ///////////////////
  119. // ButtonUI methods
  120. ///////////////////
  121.  
  122.     public Insets getDefaultMargin(AbstractButton b) { 
  123.         return ((ButtonUI) (uis.elementAt(0))).getDefaultMargin(b);
  124.     }
  125.  
  126. /////////////////////
  127. // MenuItemUI methods
  128. /////////////////////
  129.  
  130.     public void processMouseEvent(
  131.         JMenuItem item,MouseEvent e,MenuElement path[],
  132.         MenuSelectionManager manager) {
  133.         for (int i = 0; i < uis.size(); i++) {
  134.             ((MenuItemUI) (uis.elementAt(i))).processMouseEvent(
  135.             item, e, path, manager);
  136.         }
  137.     }
  138.  
  139.     public void processKeyEvent(
  140.         JMenuItem item,KeyEvent e,MenuElement path[],
  141.         MenuSelectionManager manager) {
  142.         for (int i = 0; i < uis.size(); i++) {
  143.             ((MenuItemUI) (uis.elementAt(i))).processKeyEvent(
  144.             item, e, path, manager);
  145.         }
  146.     }
  147.  
  148. /////////////////
  149. // MenuUI methods
  150. /////////////////
  151.  
  152.     public void menuCanceled(JMenu m) {
  153.         for (int i = 0; i < uis.size(); i++) {
  154.             ((MenuUI) (uis.elementAt(i))).menuCanceled(m);
  155.         }
  156.     }
  157.  
  158. }
  159.